package com.lamda.zhekou.model;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * vps的购买记录
 * Created by MJiao on 15/8/27.
 */
@Entity
public class VpsBuyRecord {

    public static final class OperatorCode {
        /**
         * 试用
         */
        public static final String TRYOUT = "试用";
        /**
         * 试用
         */
        public static final String HIRE = "租用";
        /**
         * 续费
         */
        public static final String Renew = "续费";

        /**
         * 停用
         */
        public static final String Disable = "停用";
        public static final String Init = "初始化";

    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    /**
     * 出售者
     */
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
    private User seller;

    /**
     * 消费者
     */
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
    private User customer;

    /**
     * 购买的vps名称
     */
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
    private VPS vps;

    /**
     * 出售或者续费时间
     */
    private Timestamp createTime;

    /**
     * 出售或者续费所有的金额
     */
    private float rmb;


    /**
     * 操作代码(租用, 续费 )
     */
    private String operatorCode;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public User getSeller() {
        return seller;
    }

    public void setSeller(User seller) {
        this.seller = seller;
    }

    public User getCustomer() {
        return customer;
    }

    public void setCustomer(User customer) {
        this.customer = customer;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public float getRmb() {
        return rmb;
    }

    public void setRmb(float rmb) {
        this.rmb = rmb;
    }

    public String getOperatorCode() {
        return operatorCode;
    }

    public void setOperatorCode(String operatorCode) {
        this.operatorCode = operatorCode;
    }

    public VPS getVps() {
        return vps;
    }

    public void setVps(VPS vps) {
        this.vps = vps;
    }

    @Override
    public String toString() {
        return "VpsBuyRecord{" +
                "id=" + id +
                ", seller=" + seller +
                ", customer=" + customer +
                ", createTime=" + createTime +
                ", rmb=" + rmb +
                ", operatorCode='" + operatorCode + '\'' +
                '}';
    }
}
